﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace MeizuSDK.Presentation
{
    /// <summary>
    /// 以弹出方式显示的等待对话框
    /// </summary>
    public static class PopupWaitDialog
    {
        #region DllImport
        [DllImport("MZFCWrapper.dll")]
        private static extern IntPtr MzPopupWaitDialogCtor();

        [DllImport("MZFCWrapper.dll")]
        private static extern void MzPopupWaitDialogDispose(IntPtr pObj);

        [DllImport("MZFCWrapper.dll")]
        private static extern bool MzPopupWaitDialogBeginWaitDialog(IntPtr pObj, IntPtr hwndOwner);

        [DllImport("MZFCWrapper.dll")]
        private static extern bool MzPopupWaitDialogEndWaitDialog(IntPtr pObj);
        #endregion

        private static IntPtr pObj;

        static PopupWaitDialog()
        {
            // TODO: Release?
            pObj = MzPopupWaitDialogCtor();
        }
        /// <summary>
        /// 开始显示等待对话框
        /// </summary>
        /// <param name="owner"></param>
        public static void Begin(Form owner)
        {
            // TODO: Always return false
            // 修改窗口指针参数为HWND wpwen 2010-09-02
            bool b = MzPopupWaitDialogBeginWaitDialog(pObj, owner == null ? IntPtr.Zero : owner.HWnd);
        }
        /// <summary>
        /// 关闭等待对话框
        /// </summary>
        public static void End()
        {
            bool b = MzPopupWaitDialogEndWaitDialog(pObj);
        }
    }
}
